home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Popular Request
/
By Popular Request (Arsenal Computer)(SysOptics Distribution System).ISO
/
amiga1
/
ami_n086.lha
/
output.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-23
|
2KB
|
57 lines
#include "global.h"
void write_files(files)
Name *files;
{
while (files) {
write_files(files->llink);
{
char indent_chars[500];
FILE *temp_file;
// char *temp_name = tempnam(".", 0);
//tcw
char *temp_name = tmpnam(NULL); //tcw fixed for ANSI,
// bump temp_name by 2 to get past the "t:" that is tacked on by SASC : tcw
temp_name += 2; // a hack! tcw
temp_file = fopen(temp_name, "w");
if (!temp_file) {
fprintf(stderr, "%s: can't create %s for a temporary file\n",
command_name, temp_name);
exit(-1);
}
if (verbose_flag)
fprintf(stderr, "writing %s\n", files->spelling);
write_scraps(temp_file, files->defs, 0, indent_chars,
files->debug_flag, files->tab_flag, files->indent_flag);
fclose(temp_file);
if (compare_flag)
{
FILE *old_file = fopen(files->spelling, "r");
if (old_file) {
int x, y;
temp_file = fopen(temp_name, "r");
do {
x = getc(old_file);
y = getc(temp_file);
} while (x == y && x != EOF);
fclose(old_file);
fclose(temp_file);
if (x == y)
remove(temp_name);
else {
remove(files->spelling);
rename(temp_name, files->spelling);
}
}
else
rename(temp_name, files->spelling);
}
else {
remove(files->spelling);
rename(temp_name, files->spelling);
}
}
files = files->rlink;
}
}